#ifndef FINDPATHTHREAD_H
#define FINDPATHTHREAD_H

#include <QObject>
#include <QThread>
#include <QString>
#include "data.h"

class FindpathThread : public QThread
{
    Q_OBJECT
public:
    explicit FindpathThread(QObject *parent = nullptr);

    void init(const QString& type, QHash<QString, QSharedPointer<Node>>* _id_nodes, QHash<QString, QList<Edge>>* graph, const QString& src, const QString& dst, QVector<QString>* path, bool* finded, QHash<QString, QHash<QString, QStringList>>* line, int* transfer = nullptr);

signals:
    void findPath(int path);

protected:
    void run() override;

private:
    void bfs();
    void lesstransfer();

private:
    bool* _finded;
    int* _transfer;
    QString _type; // 指定搜索类型,比如bfs
    QString _src, _dst; // 起点和终点
    QHash<QString, QSharedPointer<Node>>* _id_nodes; // id找node
    QHash<QString, QList<Edge>>* _graph; // 表
    QHash<QString, QHash<QString, QStringList>>* _lines; // 边 -- 点
    QVector<QString>* _path;
};

#endif // FINDPATHTHREAD_H
